/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

Ext.QuickTips.init();
var _pageSize = 20;

var fieldName = ['id', 'name','event', 'value', 'detail', 'code', 'time', 'endTime','pointTypeID','reportStatusCh'];
var fieldLabel = ['ID','监测点名称', '事件', '值', '详细信息', '所属单位', '发生时间', '结束时间','电压类型','上报状态'];

var loadServlet = '../../servlet/system/ExceptionLoad';

var now = new Date();

var checkboxSel = new Ext.grid.CheckboxSelectionModel();
var store;
function buildWindow() {

    store = new Ext.data.JsonStore({
        url: loadServlet,
        root: 'data',
        idProperty: 'id',
        totalProperty: 'count',
        fields: fieldName,
        baseParams: {cmd:cmd,dateFrom:now.add(Date.DAY,-7).format("Ymd"),dateTo:now.format("Ymd"), start: 0, limit: _pageSize}
        , autoLoad: true
    });

    var grid = new Ext.grid.GridPanel({
        title: _title,
        store: store,
        sm: checkboxSel,
        viewConfig: {
            forceFit: true
        },
        columns: [
            checkboxSel,
            {header: fieldLabel[0], sortable: true, dataIndex: fieldName[0], hidden: true},
            {header: fieldLabel[1], width: 80, sortable: true, dataIndex: fieldName[1]},
            {header: fieldLabel[2], width: 80, sortable: true, dataIndex: fieldName[2]},
            {header: fieldLabel[3], width: 80, sortable: true, dataIndex: fieldName[3]},
            {header: fieldLabel[4], width: 80, sortable: true, dataIndex: fieldName[4]},
            {header: fieldLabel[5], width: 80, sortable: true, dataIndex: fieldName[5]},
            {header: fieldLabel[6], width: 100, sortable: true, dataIndex: fieldName[6], xtype: 'datecolumn', format: 'Y-m-d'},
            {header: fieldLabel[7], width: 100, sortable: true, dataIndex: fieldName[7], xtype: 'datecolumn', format: 'Y-m-d'},
            {header: fieldLabel[8], width: 100, sortable: true, dataIndex: fieldName[8]},
            {header: fieldLabel[9], width: 80, sortable: true, dataIndex: fieldName[9]}
        ],        
        loadMask: true,
        tbar: new Ext.Toolbar([
            pointTypeCombo,
            pointType2Combo,
            voltageLevelCombo,
            reportCombo,
            pointText,
            "-",
            {
                xtype: 'datefield',
                id: 'DateFrom',
                format: 'Y年m月d日',
                width: 150,
                value: now.add(Date.DAY, -7),
                listeners: {
                    select: function(c, date) {                        
                        store.baseParams.dateFrom = date.format("Ymd");
                    }
                }
            },            
            {
                text: "至", xtype: 'label'
            },
            {
                xtype: 'datefield',
                id: 'DateTo',
                format: 'Y年m月d日',
                width: 150,
                value: now,
                listeners: {
                    select: function(c, date) {                        
                        store.baseParams.dateTo = date.format("Ymd");
                    }
                }
            },                    
            {
                xtype: 'button',
                text: '搜索',
                iconCls: 'icon-search',
                width: 60,
                style: {marginLeft: '20px'},
                handler: function() {
                    store.reload();
                }
            }
        ]),
        bbar: new Ext.PagingToolbar({
            pageSize: _pageSize,
            store: store,
            displayInfo: true,
            displayMsg: '显示记录：{0} - {1}   总记录：{2}',
            emptyMsg: "目前没有" + theme + '信息'
        })
    });
    //grid.el.center();
    //store.load({params: {start: 0, limit: _pageSize}});

    var applicationUI = new Ext.Viewport({
        layout: "fit",
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow);  